#ifndef RAYCASTER_H
#define RAYCASTER_H

#include <QColor>
#include "ray.h"
#include "csgnode.h"

class RayCaster
{
public:
    RayCaster();
    QColor cast_ray(Ray ray, QList<QSharedPointer<CSGNode> > *nodes);
    QColor get_point_color(float x, float y, QList<QSharedPointer<CSGNode> > *nodes);
    QColor phong_lighting(glm::vec4 point, glm::vec4 normal, Material *material);
    glm::vec4 m_grid_eye_pos;	// The position of the grid eye(eye related to grid)
    glm::vec4 m_light_pos;	// Actually, we could have more lights, but one is enough

    void rotate_x(float angle);
    void rotate_y(float angle);
    void rotate_z(float angle);

    void translate_x(float x);
    void translate_y(float y);
    void translate_z(float z);

    void move(glm::vec3 move_dir);
    void rotate(glm::vec3 rotate_vec, float angle);
private:
    glm::vec4 m_eye_world_pos;
    //	int rot_angle_x, rot_angle_y, rot_angle_z;
    glm::vec4 local_x, local_y, local_z;
    glm::mat4 m_result_orientation;

    QColor m_bgcolor;
};

#endif // RAYCASTER_H
